﻿using System.ComponentModel;

namespace ZeroSum.Extensions;

public static class EnumExtensions
{
    public static string GetDescription(this Enum value)
    {
        var attribute = value.GetType().GetField(value.ToString())
            ?.GetCustomAttributes(typeof(DescriptionAttribute), false)
            .SingleOrDefault() as DescriptionAttribute;
        return attribute == null ? value.ToString() : attribute.Description;
    }
}